package main

import (
	"fmt"
	"gqlgen-generator/config"
	"gqlgen-generator/db"
	"gqlgen-generator/gen"
	"sync"
	"time"
)

func main() {
	starttime := time.Now()
	config.Setup(`config.yaml`)
	db.Setup()
	// 并发大小
	/*	concurrentSize := 4
		c := make(chan bool, concurrentSize)
		for i := 0; i < concurrentSize; i++ {
			c <- true
		}*/

	wg := sync.WaitGroup{}
	for _, generate := range config.CONF_INSTANCE.Generates {
		wg.Add(1)
		go func(conf config.GenerateConf) {
			defer func() {
				//c <- true
				wg.Done()
			}()
			//<-c

			genService := gen.GenService{}
			genService.SetConf(conf)
			genService.Generate()

		}(generate)
	}
	wg.Wait()
	endTime := time.Now()
	fmt.Print(endTime.Sub(starttime))

}
